package com.itheima.sh;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description:
 * @Version: V1.0
 */
public class AppTest {


    public static void main(String[] args) {
//        User user = MyBeanFactory.createUser();
//        System.out.println(user);

        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
//        User bean1 = ctx.getBean(User.class);
//        User bean2 = ctx.getBean(User.class);
//        System.out.println(bean1 == bean2);
        // beanFactory 和 FactoryBean的区别
        // beanFactory是IOC容器的根接口，getBean等方法描述的Bean的属性
        // FactoryBean 是一个Bean，Bean的生命周期，Object(T) getObject 配置完成Bean，得到的是 getObject的方法的返回值
        // 如果获取工厂Bean的本身则需要 &BeanID
        Object myFactoryBean = ctx.getBean("&myFactoryBean");
        System.out.println(myFactoryBean);

    }
}
